package com.qidian.buy.content.controller;

import com.qidian.buy.content.service.IContentService;
import com.qidian.buy.entity.Content;
import com.qidian.buy.util.pojo.BuyResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 戴着假发的程序员
 * @since 2023-05-18
 */
@RestController
@RequestMapping("/buy/content")
@CrossOrigin
public class ContentController {

    @Autowired
    private IContentService contentService;

    @PostMapping("/save")
    public BuyResult save(Content content){
        return contentService.saveContent(content);
    };

    @GetMapping("/list")
    public BuyResult<Content> list(@RequestParam(defaultValue = "-1") Long catId,@RequestParam(defaultValue = "1")int page,@RequestParam(defaultValue = "10")int limit){
        return contentService.queryContentByPage(catId,page,limit);
    };

    @GetMapping("/portal")
    public BuyResult portal(){
        return contentService.queryPortal();
    }
}
